﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OperationLibrary;

namespace 计算器
{
    /// <summary>
    /// 客户端
    /// </summary>
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string strResult = "";
                try
                {
                    Console.Write("请输入一个整数：");
                    string numberA = Console.ReadLine();
                    Console.Write("请输入一个运算符（+-*/）：");
                    string operation = Console.ReadLine();
                    Console.Write("请输入一个整数：");
                    string numberB = Console.ReadLine();

                    //客户端创建对象，是通过调用工厂类的静态方式来实现的
                    Operation oper = OperationFactory.createOperation(operation);
                    oper.NumberA = Convert.ToDouble(numberA);
                    oper.NumberB = Convert.ToDouble(numberB);
                    strResult = oper.GetResult().ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                Console.WriteLine("结果是：" + strResult);

            }
            Console.ReadLine();
        }
    }
}
